package com.blb.zy_community.controller;
import com.blb.zy_community.entity.ResponseResult;
import com.blb.zy_community.utils.OssUtil;
import com.blb.zy_community.utils.OssUtil2;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@CrossOrigin
public class UploadController {
    @RequestMapping("/upload")
    public ResponseResult<String> upload(MultipartFile file) throws IOException{
        OssUtil2.upload(file.getInputStream(),file.getOriginalFilename());
        String url = OssUtil2.getURL(file.getOriginalFilename());
        return ResponseResult.ok(url);
    }
}
